// pages/user/index.js
import { getChina } from "../../utils/convertCity.js";

Page({

  /**
   * 页面的初始数据
   */
  data: {
    userInfo: {},
    hasUserInfo: false,
    city: "",
    // 被收藏的商品数量
    collectGoodsNum: 0
  },

  onShow () {
    const collectGoods = wx.getStorageSync("collectGoods") || [];
    const hasUserInfo = wx.getStorageSync("hasUserInfo");
    if (hasUserInfo) {
      const userInfo = wx.getStorageSync("userInfo");
      let city = getChina(userInfo.city);
      this.setData({
        userInfo, hasUserInfo, city, collectGoodsNum: collectGoods.length
      })
    }
  }
})